import { registerMapItem, type MapItem } from '@/map-item'
import { entityMapItem, entityMapItemType } from '../base'
import { airportLayer } from './map'
import type { Airport } from './types'
import { airportIndex } from './geo-index'
import { highLightAirportFeatures } from './feature'
import AirportInfoVue from './AirportInfo.vue'

export function initAirportMapItems() {
  registerMapItem<Airport>({
    type: entityMapItemType('Airport'),
    typeName: '机场',
    icon: 'mas-icon-Airport',
    getName: (t) => t.id,
    index: {
      enable: () => airportLayer.visible,
      search: (lng, lat, r) => airportIndex.search(lng, lat, r)
    },
    highlight: highLightAirportFeatures,
    infoView: AirportInfoVue
  })
}

export function airportMapItem(id: string): MapItem<Airport> {
  return entityMapItem('Airport', id)
}
